import java.util.Arrays;

//队列 插入数据只能在尾删除数据只能在头
class two{
    //循环列表
    private int DEFUAT = 6;
    private int[] arr = new int[DEFUAT];
    private int front = 0;
    private int rear = 0;

    private int isFall() {
        if ((rear + 1) % DEFUAT == front) {
            //满了 实际容量DEFUAT-1
            return 1;
        }
        return 0;
    }

    public void push(int val) {
        if (isFall() == 0) {
            arr[rear++] = val;
        } else {
            System.out.println("满了");
        }
    }

    public void pop(int val) {
        front = (front + 1) % DEFUAT;
    }

    public int getCount() {
        return (rear-front+DEFUAT)%DEFUAT;
    }

    public int getFront() {
        return front;
    }

    public int getRear() {
        return rear;
    }

    public int getVal(int index) {
        return arr[index];
    }
    @Override
    public String toString() {
        return "two{" +
                "arr=" + Arrays.toString(arr) +
                '}';
    }
}

public class duilie {
    public static void main(String[] args) {
        two h = new two();
        for (int i = 1; i < 7; i++) {
            h.push(i);
        }
        System.out.println(h);
        System.out.println(h.getCount());
        for (int i = 0; i < 4; i++) {
            h.pop(i);
        }
        System.out.println("有效数据 = "+h.getCount());
        System.out.println("front = "+h.getVal(h.getFront()));
        System.out.println("rear = "+h.getVal(h.getRear()));
    }
}
